﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.Storage;
using Windows.Storage.Streams;
using Windows.ApplicationModel.Activation;
using Windows.UI.Core;
using System.Diagnostics;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238

namespace SplitViewOptions
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class localhtmlPage : Page
    {
        SystemNavigationManager currentView = SystemNavigationManager.GetForCurrentView();
        public localhtmlPage()
        {
            this.InitializeComponent();
            currentView.BackRequested += CurrentView_BackRequested;
        }
        private  void CurrentView_BackRequested(object sender, BackRequestedEventArgs e)
        {
            this.Frame.Navigate(typeof(MainPage));
        }
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
           
            var args = e.Parameter as FileActivatedEventArgs;
            
            if (args != null)
            {

                string output = "Files received: " + args.Files.Count + "\n";
               
                if (args.Files.Count > 0)
                {

                    StorageFile file = args.Files[0] as StorageFile;
                    if (file != null)
                    {


                        string read = await FileIO.ReadTextAsync(file, UnicodeEncoding.Utf16BE);
                        Debug.WriteLine(read);
                        box.NavigateToString(read);
                       
                    }
                }


            }
       
    }

    }
}
